package com.etrans.baf.analyse.task.alarm.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.etrans.baf.analyse.task.alarm.service.AnalyseService;

@Component("analyseAlarm")
@Controller
@RequestMapping("/task/alarm/analyseAlarm/*")
public class AnalyseAlarm {
	
	@Autowired
	private AnalyseService analyseService;
	
	private static int count=0;
	
	static final Logger logger = LoggerFactory.getLogger(AnalyseAlarm.class);
	/**
	 * 报警分析
	 */
	@RequestMapping(value = "dataAnalyse.html")
	public void analyseAlarm(){
//		logger.info("报警分析开始----------------");
		if(count==0){
			analyseService.initVehicleInfo();
		}
		try {
			analyseService.analyseAlarm(); 
		} catch (Exception e) {
			e.printStackTrace();
		}
		count++;
		if(count==10){  // 程序一分钟调用一次， （10秒） 刷新车辆信息 
			count=0;
		}
//		logger.info("报警分析结束----------------");
	}
	
}
